const { resolve } = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const TerserWebpackPlugin = require('terser-webpack-plugin')

const entry = {
  index: {
    import: resolve(__dirname, 'src/entry/index.ts'),
  },
};

const output = {
  path: resolve(__dirname, 'build'),
  filename: '[name].js',
  clean: true,
};

const MODULE = {
  rules: [
    {
      test: /\.ts$/,
      include: [ 
        resolve(__dirname, 'src'),
      ],
      use: ['ts-loader']
    },
  ]
}

const plugins = [
  new HtmlWebpackPlugin(),
  new TerserWebpackPlugin()
]

module.exports = {
  entry,
  output,
  mode: 'development',
  devServer: {
    open: true
  },
  module: MODULE,
  plugins,
  devtool: 'source-map'
}